/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.cibertec.dawii.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Manuel Eguiluz
 */
@Entity
@Table(name = "problem_history", catalog = "uservoice", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ProblemHistory.findAll", query = "SELECT p FROM ProblemHistory p"),
    @NamedQuery(name = "ProblemHistory.findById", query = "SELECT p FROM ProblemHistory p WHERE p.id = :id"),
    @NamedQuery(name = "ProblemHistory.findByFixDatetime", query = "SELECT p FROM ProblemHistory p WHERE p.fixDatetime = :fixDatetime")})
public class ProblemHistory implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(nullable = false)
    private Integer id;
    @Basic(optional = false)
    @Column(name = "fix_datetime", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date fixDatetime;
    @JoinColumn(name = "problem", referencedColumnName = "id", nullable = false)
    @ManyToOne(optional = false)
    private Problem problem;
    @JoinColumn(name = "assigned_staff", referencedColumnName = "id", nullable = false)
    @ManyToOne(optional = false)
    private SupportStaff assignedStaff;
    @JoinColumn(name = "problem_status", referencedColumnName = "id", nullable = false)
    @ManyToOne(optional = false)
    private ProblemStatus problemStatus;
    @JoinColumn(name = "priority_level", referencedColumnName = "id", nullable = false)
    @ManyToOne(optional = false)
    private PriorityLevel priorityLevel;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "problemHistory")
    private Collection<Resolution> resolutionCollection;

    public ProblemHistory() {
    }

    public ProblemHistory(Integer id) {
        this.id = id;
    }

    public ProblemHistory(Integer id, Date fixDatetime) {
        this.id = id;
        this.fixDatetime = fixDatetime;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getFixDatetime() {
        return fixDatetime;
    }

    public void setFixDatetime(Date fixDatetime) {
        this.fixDatetime = fixDatetime;
    }

    public Problem getProblem() {
        return problem;
    }

    public void setProblem(Problem problem) {
        this.problem = problem;
    }

    public SupportStaff getAssignedStaff() {
        return assignedStaff;
    }

    public void setAssignedStaff(SupportStaff assignedStaff) {
        this.assignedStaff = assignedStaff;
    }

    public ProblemStatus getProblemStatus() {
        return problemStatus;
    }

    public void setProblemStatus(ProblemStatus problemStatus) {
        this.problemStatus = problemStatus;
    }

    public PriorityLevel getPriorityLevel() {
        return priorityLevel;
    }

    public void setPriorityLevel(PriorityLevel priorityLevel) {
        this.priorityLevel = priorityLevel;
    }

    @XmlTransient
    public Collection<Resolution> getResolutionCollection() {
        return resolutionCollection;
    }

    public void setResolutionCollection(Collection<Resolution> resolutionCollection) {
        this.resolutionCollection = resolutionCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ProblemHistory)) {
            return false;
        }
        ProblemHistory other = (ProblemHistory) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "edu.cibertec.dawii.entity.ProblemHistory[ id=" + id + " ]";
    }
    
}
